//
//  ZJProjectDetailModel.m
//  这家测试项目
//
//  Created by IOS_DEVELOPER on 2017/6/29.
//  Copyright © 2017年 陈志凌. All rights reserved.
//

#import "ZJProjectDetailModel.h"
#import <objc/message.h>
//项目详情
ZJProjectDetailModel * projectModel;
@implementation ZJProjectDetailModel
+(void)getProjectDetail{
    NSDictionary *parameter = [LRNetwork requestParameter:@{}];
    NSString *url = [LRNetwork requestURL:@"cgi/project.php"];

    [LRNetwork netRequestPOSTWithRequestURL:url withParameter:parameter withReturnValeuBlock:^(id returnValue) {
        
        projectModel = [[ZJProjectDetailModel alloc]init];
        projectModel = [ZJProjectDetailModel mj_objectWithKeyValues:returnValue[@"project"]];
        
        SYN_PROJECT(projectModel);
    } withErrorCodeBlock:^(NSInteger errorCode, NSString *errorMessage) {
        [HUD showErrorMsg:errorMessage];
    } withFailureBlock:^{
        
    }];
}
-(void)encodeWithCoder:(NSCoder *)aCoder{
    unsigned int count = 0;
    Ivar * ivars = class_copyIvarList([self class], &count);
    for (int i = 0 ; i < count; i++) {
        Ivar ivar = ivars[i];
        const char * name = ivar_getName(ivar);
        NSString * key = [NSString stringWithUTF8String:name];
        //归档
        [aCoder encodeObject:[self valueForKey:key] forKey:key];
    }
    NSLog(@"更新楼盘信息");
    free(ivars);
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        //解档
        unsigned int count = 0;
        Ivar * ivars = class_copyIvarList([self class], &count);
        for (int i = 0 ; i < count; i++) {
            Ivar ivar = ivars[i];
            const char * name = ivar_getName(ivar);
            NSString * key = [NSString stringWithUTF8String:name];
            //解档
            id value = [aDecoder decodeObjectForKey:key];
            [self setValue:value forKey:key];
        }
        NSLog(@"成功读取楼盘信息");
        free(ivars);
    }
    return self;
}
@end
